#ifndef RULES_H
#define RULES_H
#include "fw5.h"
#include "network.h"
#include <linux/inet.h>

#define NUM_OF_DEF_RULES 4		// number of pre defined rules
#define NUM_OF_PROTOCOLS 3		// number of protocols
#define LAST_RULE_PROT 255		// end protocol
#define UNMATCHED_PACKET -1		// no rule was found
#define STRING_UNMATCHED -1
#define STRING_MATCH_DEFAULT 0


/*
 * function  checkPermission:
 * checks if the rules allow or deny conversation
 * between specific clientIP and serverIP
 * between specific clientIP and serverIP
 * params		: full rules matrix, clientID, serverID
 * return value : VERDICT_ALLOW - if allowed, VERDICT_DROP - otherwise
 * assumptions  : call is made after a call to LoadRules, 
 * 				  clientID and serverID are at range 0-255   
 */
static char checkPermission(rawPacket_t* packet,int inspectData, int *matchedRuleIndex, int *matchedStringIndex);

/*
 * function loadDeafultRules
 * loads the pre defined rules
 * assumptions: should be called before any rules is added and after allocation of rules array
 */ 
static void loadDefaultRules(void);
/*
 * function matchString
 * Tries to find the first time that strFind is in strData (as a whole string)
 * params		: strData is the string to search in, lenData is its length
 * 				  strFind is the string to find, lenSearch is its length
 * return value	: the position if found, otherwise returns STRING_UNMATCHED
 * assumptions	:  lenData and lenSearch are in host endianess format
 */
static int matchString(char *strData, unsigned int lenData, char *strFind, unsigned int lenSearch);
#endif

